feat(ai): secure LLM config with provider presets and api key protection#25
Merged
Conversation
- Config: add [llm] section (api_key, provider, model) - LLM: AGIT_LLM_PROVIDER preset table (openai/deepseek/anthropic/moonshot/zhipu/ollama) - Priority: env var > repo .agit/config.toml > global ~/.agitconfig.toml > default - LLM API: add 30s timeout, better error messages with config hints - commit --ai: show detailed config guide when no API key set
- Config.llm, LlmConfig: #[allow(dead_code)] - LLM_PROVIDERS, resolve_llm_provider: #[allow(dead_code)] - Blob import + build_staged_summary: #[cfg(feature = "ai")]
f904ef5 to
7fe58fe
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
三层安全改进:
1. API key 持久化
~/.agitconfig.toml(全局配置文件)存储 API key,配一次永久生效.agit/config.toml读取 api_key,防止密钥泄漏到仓库2. 厂商预设
内置 6 家:openai / deepseek / anthropic / moonshot / zhipu / ollama
只需配置
provider = "deepseek",自动匹配 endpoint 和默认 model3. init 安全守卫
agit init始终创建.gitignore,包含.agit/防止配置目录被意外提交配置方式
# 环境变量 — 一次性 AGIT_LLM_API_KEY=sk-xxx AGIT_LLM_PROVIDER=deepseek agit commit --ai安全
~/.agitconfig.toml(全局)和 env 中读取.agit/config.toml(仓库级)的 api_key 字段被忽略init自动将.agit/写入.gitignore